package com.meilai.project.controller.web.business.workbench;

import com.meilai.project.dto.CommonResult;
import com.meilai.project.dto.business.workbench.FillReasonsForNotCooperatingDTO;
import com.meilai.project.service.business.workbench.CompanyMonthService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/web/companyMonth")
public class CompanyMonthController {

    @Autowired
    private CompanyMonthService companyMonthService;


    @GetMapping("/queryCompanyMonthByMonth")
    @ApiOperation("查询月目标数据")
    public CommonResult queryCompanyMonthByMonth(@RequestParam("year") Integer year, @RequestParam("month") Integer month) {
        return new CommonResult().success(companyMonthService.queryCompanyMonthByMonth(year, month));
    }

    @GetMapping("/queryCompanyMonthPlanByMonth")
    @ApiOperation("查询月计划")
    public CommonResult queryCompanyMonthPlanByMonth(@RequestParam("year") Integer year, @RequestParam("month") Integer month) {
        return new CommonResult().success(companyMonthService.queryCompanyMonthPlanByMonth(year, month));
    }

    @PostMapping("/fillReasonsForNotCooperating")
    @ApiOperation("填写未成交原因")
    public CommonResult fillReasonsForNotCooperating(@RequestBody List<FillReasonsForNotCooperatingDTO> dtoList) {
        return new CommonResult().success(companyMonthService.fillReasonsForNotCooperating(dtoList));
    }

    @PostMapping("/fillAnnotation")
    @ApiOperation("填写批注")
    public CommonResult fillAnnotation(@RequestParam("customer_id") Long customer_id, @RequestParam("comments") String comments) {
        return new CommonResult().success(companyMonthService.fillAnnotation(customer_id, comments));
    }
}
